import axios from 'axios'

axios.defaults.headers['content-Type'] = "application/json;charset = utf-8";
axios.defaults.headers['Authorization'] = localStorage.getItem('token')? localStorage.getItem('token'):'';
//axios全局配置
axios.interceptors.request.use(function (config) {
    // config.headers = {
    //     'Accept':"application/json, text/plain, */*",
    //     'Content-Type' :"application/json; charset = utf-8",
    //     "Authorization": localStorage.getItem('token')? localStorage.getItem('token') : "",
    // };
    config.timeout = 3000;
    config.baseURL = 'http://192.168.1.103:8088/api';
    return config;
})
axios.interceptors.response.use(response =>{
    //对响应数据做点什么
    //response.status !== 204 && (response.data.msg = (typeof response.data.msg === 'array') ? response.data.msg[0] : response.data.msg);
    //return response.data;
    // if(response.headers.authorization){
    //     localStorage.setItem('token',response.headers.authorization)
    // }
    return response.data;
})
export default axios